home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWEvents / Include / FWEventH.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  12.4 KB  |  282 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWEventH.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWEVENTH_H
  11. #define FWEVENTH_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #ifndef FWRUNTYP_H
  18. #include "FWRunTyp.h"
  19. #endif
  20.  
  21. // ----- OpenDoc Includes -----
  22.  
  23. #ifndef _ODTYPES_
  24. #include <ODTypes.h>
  25. #endif
  26.  
  27. #if FW_LIB_EXPORT_PRAGMAS
  28. #pragma lib_export on
  29. #endif
  30.  
  31. //========================================================================================
  32. //    Forward Declarations
  33. //========================================================================================
  34.  
  35. class FW_CLASS_ATTR FW_CPoint;
  36. class FW_CLASS_ATTR FW_CNullEvent;
  37. class FW_CLASS_ATTR FW_CMouseEvent;
  38. class FW_CLASS_ATTR FW_CEmbeddedMouseEvent;
  39. class FW_CLASS_ATTR FW_CBorderMouseEvent;
  40. class FW_CLASS_ATTR FW_CVirtualKeyEvent;
  41. class FW_CLASS_ATTR FW_CCharKeyEvent;
  42. class FW_CLASS_ATTR FW_CActivateEvent;
  43. class FW_CLASS_ATTR FW_CSuspendResumeEvent;
  44. class FW_CLASS_ATTR FW_CMenuEvent;
  45. class FW_CLASS_ATTR FW_CMacWindowEvent;
  46. class FW_CLASS_ATTR FW_CMenuBar;
  47. class FW_CLASS_ATTR ODFrame;
  48. class FW_CLASS_ATTR ODFacet;
  49. class FW_CLASS_ATTR FW_CPrivOrderedCollection;
  50. class FW_CLASS_ATTR FW_MEventHandler;
  51.  
  52. //========================================================================================
  53. //     typedef
  54. //========================================================================================
  55.  
  56. typedef unsigned long FW_Priority;
  57.  
  58. //========================================================================================
  59. //     Constants
  60. //========================================================================================
  61.  
  62. const ODID kNoIdentifier = 0xFFFFFFFFL;
  63. const FW_Priority kNoPriority = 1000;            // Pick some large number here?
  64.  
  65. //========================================================================================
  66. //    struct FW_SEventHandlerPartInfo
  67. //========================================================================================
  68. //    We put a pointer of this structure into the partInfo of a frame. FW_SEventHandlerPartInfo
  69. //    is subclassed in the framework layer.
  70.  
  71. struct FW_SEventHandlerPartInfo
  72. {
  73.     FW_MEventHandler* fEventHandler;
  74. };
  75.  
  76. //========================================================================================
  77. //     class FW_MEventHandler
  78. //========================================================================================
  79.  
  80. class FW_CLASS_ATTR FW_MEventHandler
  81. {
  82. public:
  83.     FW_DECLARE_CLASS
  84.  
  85.     typedef FW_MEventHandler* FW_MEventHandlerPtr;
  86.     typedef ODID EventHandlerId;
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    Constructors/Destructor
  90. //
  91. protected:
  92.     FW_MEventHandler();
  93.     FW_MEventHandler(Environment* ev, ODID theID, FW_MEventHandler* nextEventHandler, FW_Boolean enabled, FW_Priority thePriority);
  94.  
  95. public:
  96.     virtual ~ FW_MEventHandler();
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    New API
  100. //
  101. public:
  102.     ODID                        GetIdentifier(Environment* ev) const;
  103.     virtual void                SetIdentifier(Environment* ev, ODID identifier);
  104.     
  105.     FW_MEventHandler*            GetNextEventHandler(Environment* ev) const;
  106.     void                        SetNextEventHandler(Environment* ev, FW_MEventHandler* nextEventHandler);
  107.     
  108.     virtual FW_Boolean            IsActive(Environment* ev) const;
  109.     virtual FW_Boolean            Activate(Environment* ev);
  110.     virtual void                Deactivate(Environment* ev);
  111.     
  112.     virtual FW_Boolean            IsEnabled(Environment* ev) const;
  113.     virtual FW_Boolean            Enable(Environment* ev);
  114.     virtual void                Disable(Environment* ev);
  115.     
  116.     virtual FW_Priority            GetPriority(Environment* ev) const;
  117.     virtual void                SetPriority(Environment* ev, FW_Priority thePriority);
  118.     
  119.     // ----- Event handler management -----
  120.  
  121.     virtual void                 AdoptEventHandler(Environment* ev, FW_MEventHandler* eventHandler);
  122.     virtual FW_MEventHandler*     RemoveEventHandler(Environment* ev, ODID theID);
  123.     virtual FW_MEventHandler*     RemoveEventHandler(Environment* ev, FW_MEventHandler* eventHandler);
  124.  
  125.     // ----- Event Handling Protocal -----
  126.  
  127.     virtual FW_Boolean             HandleIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
  128.     virtual FW_Boolean             DoIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
  129.     
  130.     virtual FW_Boolean             HandleMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  131.     virtual FW_Boolean             DoMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  132.  
  133.     virtual FW_Boolean             HandleMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  134.     virtual FW_Boolean             DoMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  135.  
  136.     virtual FW_Boolean             HandleMouseLeave(Environment* ev, ODFacet* odFacet);
  137.     virtual FW_Boolean             DoMouseLeave(Environment* ev, ODFacet* odFacet);
  138.  
  139.     virtual FW_Boolean             HandleMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  140.     virtual FW_Boolean            DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  141.  
  142.     virtual FW_Boolean             HandleBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  143.     virtual FW_Boolean             DoBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  144.     
  145.     virtual FW_Boolean             HandleMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  146.     virtual FW_Boolean             DoMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  147.     
  148.     virtual FW_Boolean             HandleMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  149.     virtual FW_Boolean             DoMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  150.  
  151.     virtual FW_Boolean             HandleBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  152.     virtual FW_Boolean             DoBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  153.  
  154.     virtual FW_Boolean             HandleMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  155.     virtual FW_Boolean             DoMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  156.     
  157.     virtual FW_Boolean             HandleMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
  158.     virtual FW_Boolean             DoMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
  159.  
  160.     virtual FW_Boolean             HandleVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
  161.     virtual FW_Boolean             DoVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
  162.  
  163.     virtual FW_Boolean             HandleCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
  164.     virtual FW_Boolean             DoCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
  165.  
  166.     virtual FW_Boolean             HandleActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
  167.     virtual FW_Boolean             DoActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
  168.  
  169.     virtual FW_Boolean             HandleSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
  170.     virtual FW_Boolean             DoSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
  171.  
  172.     virtual FW_Boolean             HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
  173.     virtual FW_Boolean             DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
  174.  
  175.     virtual FW_Boolean             HandleAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  176.     virtual FW_Boolean             DoAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  177.     
  178. #ifdef FW_BUILD_MAC
  179.     virtual FW_Boolean             HandleWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
  180.     virtual FW_Boolean             DoWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
  181. #endif    
  182.     
  183.     // ----- Target management -----
  184.  
  185.     virtual FW_MEventHandler*     GetTarget(Environment* ev) const;
  186.     virtual void                 SetTarget(Environment* ev, FW_MEventHandler* theTarget);
  187.     virtual FW_Boolean             IsTarget(Environment* ev);
  188.     virtual FW_Boolean             BecomeTarget(Environment* ev);
  189.     virtual FW_Boolean             ResignTarget(Environment* ev);
  190.     virtual FW_Boolean             WantsToBeTarget(Environment* ev);
  191.     virtual long                 WillingToResignTarget(Environment* ev);
  192.     virtual void                 TargetValidationSucceeded(Environment* ev);
  193.     virtual void                 TargetValidationFailed(Environment* ev, long reason);
  194.  
  195.     // ----- Private Method -----
  196.     virtual FW_MEventHandler*     PrivGetEventHandlerContaining(Environment* ev, ODFacet* facet, const FW_CPoint& whereInFrame);
  197.  
  198.     //------------------------------------------------------------------------------------
  199.     // Conversion utilities
  200.     //------------------------------------------------------------------------------------
  201.     
  202.     static FW_MEventHandler*    ODFrameToEventHandler(Environment* ev, ODFrame* theFrame);
  203.  
  204. //------------------------------------------------------------------------------------
  205. //    Internal use Only
  206. //
  207. public:
  208.     // ----- Dispatching -----
  209.     FW_Boolean            DispatchMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  210.     FW_Boolean            DispatchBGMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  211.     FW_Boolean            DispatchMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  212.     FW_Boolean             DispatchIdle(Environment* ev, const FW_CNullEvent& theNullEvent);
  213.     FW_Boolean             DispatchMouseEnter(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  214.     FW_Boolean             DispatchMouseWithin(Environment* ev, ODFacet* odFacet, const FW_CPoint& theMousePoint);
  215.     FW_Boolean             DispatchMouseLeave(Environment* ev, ODFacet* odFacet);
  216.     FW_Boolean             DispatchMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  217.     FW_Boolean             DispatchBGMouseDownInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  218.     FW_Boolean             DispatchMouseUpInEmbeddedFrame(Environment* ev, const FW_CEmbeddedMouseEvent& theEmbeddedMouseEvent);
  219.     FW_Boolean             DispatchMouseDownInEmbeddedFrameBorder(Environment* ev, const FW_CBorderMouseEvent& theBorderMouseEvent);
  220.     FW_Boolean             DispatchVirtualKey(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent);
  221.     FW_Boolean             DispatchCharKey(Environment* ev, const FW_CCharKeyEvent& theCharKeyEvent);
  222.     FW_Boolean             DispatchActivateEvent(Environment* ev, const FW_CActivateEvent& theActivateEvent);
  223.     FW_Boolean             DispatchSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& theSuspendResumeEvent);
  224.     FW_Boolean             DispatchMenuEvent(Environment* ev, const FW_CMenuEvent& theMenuEvent);
  225.     FW_Boolean             DispatchAdjustMenus(Environment *ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  226.  
  227. #ifdef FW_BUILD_MAC
  228.     FW_Boolean             DispatchWindowEvent(Environment* ev, const FW_CMacWindowEvent& windowEvent);
  229. #endif
  230.  
  231. protected:
  232.     virtual void         CreateEventHandlers(Environment* ev);
  233.     
  234. private:
  235.     void                PrivInsert(Environment* ev, FW_MEventHandler* eventHandler);
  236.         
  237. //----------------------------------------------------------------------------------------
  238. //    Data Members
  239. //
  240. private:
  241.     ODID                        fIdentifier;
  242.     FW_MEventHandler            *fNextEventHandler;
  243.     FW_Boolean                    fActive;
  244.     FW_Boolean                    fEnabled;
  245.     FW_Priority                    fPriority;
  246.     FW_CPrivOrderedCollection*     fEventHandlers;
  247. };
  248.  
  249. //========================================================================================
  250. //     Inlines
  251. //========================================================================================
  252.  
  253. //----------------------------------------------------------------------------------------
  254. //     FW_MEventHandler::GetIdentifier()
  255. //----------------------------------------------------------------------------------------
  256. inline ODID FW_MEventHandler::GetIdentifier(Environment* ev) const
  257. {
  258.     return fIdentifier;
  259. }
  260.  
  261. //----------------------------------------------------------------------------------------
  262. //     FW_MEventHandler::GetNextEventHandler()
  263. //----------------------------------------------------------------------------------------
  264. inline FW_MEventHandler* FW_MEventHandler::GetNextEventHandler(Environment* ev) const
  265. {
  266.     return fNextEventHandler;
  267. }
  268.  
  269. //----------------------------------------------------------------------------------------
  270. //     FW_MEventHandler::SetNextEventHandler()
  271. //----------------------------------------------------------------------------------------
  272. inline void FW_MEventHandler::SetNextEventHandler(Environment* ev, FW_MEventHandler* nextEventHandler)
  273. {
  274.     fNextEventHandler = nextEventHandler;
  275. }
  276.  
  277. #if FW_LIB_EXPORT_PRAGMAS
  278. #pragma lib_export off
  279. #endif
  280.  
  281. #endif
  282.